<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>后台管理系统</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- favicon
		============================================ -->
    <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
    <!-- Google Fonts
		============================================ -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700,900" rel="stylesheet">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/bootstrap.min.css">

    <!-- Lobibox CSS
        ============================================ -->
    <link rel="stylesheet" href="css/notifications/Lobibox.min.css">

    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/font-awesome.min.css">


    <!-- DatetimePicker CSS
        ============================================ -->
    <link rel="stylesheet" href="css/datetimepicker/bootstrap-datetimepicker.min.css">

    <!-- owl.carousel CSS
		============================================ -->
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/owl.theme.css">
    <link rel="stylesheet" href="css/owl.transitions.css">
    <!-- animate CSS
		============================================ -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- normalize CSS
		============================================ -->
    <link rel="stylesheet" href="css/normalize.css">
    <!-- meanmenu icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/meanmenu.min.css">
    <!-- main CSS
		============================================ -->
    <link rel="stylesheet" href="css/main.css">
    <!-- educate icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/educate-custon-icon.css">
    <!-- morrisjs CSS
		============================================ -->
    <link rel="stylesheet" href="css/morrisjs/morris.css">
    <!-- mCustomScrollbar CSS
		============================================ -->
    <link rel="stylesheet" href="css/scrollbar/jquery.mCustomScrollbar.min.css">
    <!-- metisMenu CSS
		============================================ -->
    <link rel="stylesheet" href="css/metisMenu/metisMenu.min.css">
    <link rel="stylesheet" href="css/metisMenu/metisMenu-vertical.css">
    <!-- calendar CSS
		============================================ -->
    <link rel="stylesheet" href="css/calendar/fullcalendar.min.css">
    <link rel="stylesheet" href="css/calendar/fullcalendar.print.min.css">

    <!-- form CSS
		============================================ -->
    <link rel="stylesheet" href="css/form/all-type-forms.css">

    <!-- style CSS
		============================================ -->
    <link rel="stylesheet" href="css/style.css">
    <!-- responsive CSS
		============================================ -->
    <link rel="stylesheet" href="css/responsive.css">
    <!-- modernizr JS
		============================================ -->
    <script src="vendor/modernizr-2.8.3.min.js"></script>
    <style>
        .modal-dialog {
            width: 680px;
        }
        .pagination {
            margin-top: 0;
            margin-bottom: 0;
        }

        .table th, .table td {
            text-align: center;
            vertical-align: middle !important;
        }
    </style>
</head>

<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Start Left menu area -->
<div class="left-sidebar-pro">
    <nav id="sidebar" class="">
        <div class="sidebar-header">
            <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt="" /></a>
            <strong><a href="index.html"><img src="img/logo/logosn.png" alt="" /></a></strong>
        </div>
        <div class="left-custom-menu-adp-wrap comment-scrollbar">
            <nav class="sidebar-nav left-sidebar-menu-pro">
                <ul class="metismenu" id="menu1">
                    <li>
                        <a title="Landing Page" href="report.html" aria-expanded="false"><span class="fa fa-user-circle-o" aria-hidden="true"></span> <span class="mini-click-non">商城数据</span></a>
                    </li>
                    <li class="active">
                        <a class="has-arrow" href="index.html">
                            <span class="fa fa-id-card"></span>
                            <span class="mini-click-non">用户信息</span>
                        </a>
                        <ul class="submenu-angle" aria-expanded="true">
                            <li><a href="index.html"><span class="mini-sub-pro">用户列表</span></a></li>
                            <li><a href="goodsManager.html"><span class="mini-sub-pro">商品列表</span></a></li>
                            <li><a href="order.html"><span class="mini-sub-pro">订单管理</span></a></li>
                            <li><a href="classify.html"><span class="mini-sub-pro">类目管理</span></a></li>
                            <li><a href="sc.html"><span class="mini-sub-pro">客户服务</span></a></li>
                            <li><a href="notification.html"><span class="mini-sub-pro">通知管理</span></a></li>
                        </ul>
                    </li>
                    <li>
                        <a title="Landing Page" href="adminUser.html" aria-expanded="false"><span class="fa fa-user-circle-o" aria-hidden="true"></span> <span class="mini-click-non">系统用户</span></a>
                    </li>
                </ul>
            </nav>
        </div>
    </nav>
</div>
<!-- End Left menu area -->
<!-- Start Welcome area -->
<div class="all-content-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="logo-pro">
                    <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt="" /></a>
                </div>
            </div>
        </div>
    </div>
    <div class="header-advance-area">
        <div class="header-top-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="header-top-wraper">
                            <div class="row">
                                <div class="col-lg-1 col-md-0 col-sm-1 col-xs-12">
                                    <div class="menu-switcher-pro">
                                        <button type="button" id="sidebarCollapse" class="btn bar-button-pro header-drl-controller-btn btn-info navbar-btn">
                                            <i class="fa fa-bars"></i>
                                        </button>
                                    </div>
                                </div>

                                <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 col-lg-offset-6 col-md-offse-7 col-sm-offse-6 col-xs-offse-12">
                                    <div class="header-right-info">
                                        <ul class="nav navbar-nav mai-top-nav header-right-menu">
                                            <li class="nav-item">
                                                <div class="dropdown" id="notifyMenu">
                                                    <button type="button" class="btn btn-danger dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">
                                                        <i class="fa fa-bell" aria-hidden="true"></i>
                                                        <span class="badge" id="unreadNotify">0</span>
                                                        <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu"  aria-labelledby="dropdownMenu1" v-if="notifyData.length>0">
                                                        <!--消息列表-->
                                                        <li  v-for="notify in notifyData"  >
                                                            <a href="javascript:void(0)" v-on:click="fn($event)" :value="notify.path" :nid="notify.nid">
                                                                <div class="notification-content">
                                                                    <span class="bg-info" >{{notify.updateTime}}</span>
                                                                    <h5 style="margin-top: 10px">{{notify.title}}</h5>
                                                                    <p>点击查看详细信息</p>
                                                                </div>
                                                            </a>
                                                        </li>
                                                    </ul>
                                                    <ul class="dropdown-menu"  id="" aria-labelledby="dropdownMenu1" v-else>
                                                        <li>
                                                            <span style="font-size: 10px;color: darkgrey">暂无新的通知</span>
                                                        </li>
                                                        <li>
                                                            <a href="notification.html">查看所有通知</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </li>
                                            <li class="nav-item">
                                                <a href="#" data-toggle="dropdown" role="button" aria-expanded="false" class="nav-link dropdown-toggle">
                                                    <img id="headImgs" src="img/product/pro4.jpg" alt="" />
                                                    <span class="admin-name" id="headName"></span>
                                                    <i class="fa fa-angle-down edu-icon edu-down-arrow"></i>
                                                </a>
                                                <ul role="menu" class="dropdown-header-top author-log dropdown-menu animated zoomIn">

                                                    <li><a onclick="logOut()"><span class="edu-icon edu-locked author-log-ic" style="cursor:pointer"></span>登出</a>
                                                    </li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="container-fluid" style="padding: 20px 15px 0 15px;">
            <div style="background-color: #ffffff; border-radius: 3px; padding: 12px;">
                <form class="form-inline" onsubmit="javascript: return false;">
                    <div class="form-group">
                        <label for="name">用户名: </label>
                        <input autocomplete="off" class="form-control" id="name">
                    </div>
                    <div class="form-group">
                        <label for="gender">性别: </label>
                        <select class="form-control" id="gender">
                            <option value="-1">全部</option>
                            <option value="F">女</option>
                            <option value="M">男</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="status">状态: </label>
                        <select class="form-control" id="status">
                            <option value="-1">全部</option>
                            <option value="1">激活</option>
                            <option value="0">未激活</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="email">邮件: </label>
                        <input autocomplete="off" class="form-control" id="email">
                    </div>
                    <div class="form-group">
                        <label>注册日期: </label>
                        <input class="form-control" readonly autocomplete="off" id="beginRegisterDate"> -
                        <input autocomplete="off" readonly class="form-control" id="endRegisterDate">
                    </div>
                    <div class="form-group">
                        <button class="btn btn-danger" onclick="querySearch()">搜索</button>
                        <button autocomplete="off" class="btn btn-danger" onclick="resetSearch()">重置</button>
                    </div>
                </form>
                <!--
                额外加一列，写个按钮查看用户的地址信息。
                -->
                <table id="dataTable" class="table table-hover table-bordered"></table>
                <div id="userTableToolbar" style="margin: 10px 0px;">
                    <button onclick="downloadExcel()" class="btn btn-primary">导出</button>
                    <button  onclick="clickFileInput()"  class="btn btn-danger">导入</button>
                    <input type="file" id="fileid" onchange="uploadExcel(this)" style="display:none;" name="excel" value="" />
                    <a href="http://localhost:8080/posterior_system_war_exploded/user/excelmodel">下载模板</a>
                </div>
                <div class="modal" id="showAddressModal" data-backdrop="static">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button class="close" onclick="address()">
                                    <span>&times;</span>
                                </button>
                                <h3 class="modal-title">收货地址</h3>
                            </div>
                            <div class="modal-body">
                                <table id="addressDataTable" class="table table-striped"></table>
                            </div>
                        </div>
                    </div>
                </div>
<!--                购物车模态框-->
                <div class="modal" id="showShoppingCart" data-backdrop="static">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button class="close" onclick="shoping()">
                                    <span>&times;</span>
                                </button>
                                <h3 class="modal-title">购物车</h3>
                            </div>
                            <div class="modal-body">
                                <table id="shoppingCartDataTable" class="table table-striped"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- jquery
============================================ -->
<script src="js/vendor/jquery-1.12.4.min.js"></script>
<!-- bootstrap JS
============================================ -->
<script src="js/bootstrap.min.js"></script>
<!-- wow JS  动画效果js
============================================ -->
<script src="js/wow.min.js"></script>
<!-- price-slider JS
============================================ -->
<script src="js/jquery-price-slider.js"></script>
<!-- meanmenu JS
============================================ -->
<script src="js/jquery.meanmenu.js"></script>
<!-- owl.carousel JS
============================================ -->
<script src="js/owl.carousel.min.js"></script>
<!-- sticky JS
============================================ -->
<script src="js/jquery.sticky.js"></script>
<!-- scrollUp JS
============================================ -->
<script src="js/jquery.scrollUp.min.js"></script>
<!-- counterup JS
============================================ -->
<script src="js/counterup/jquery.counterup.min.js"></script>
<script src="js/counterup/waypoints.min.js"></script>
<script src="js/counterup/counterup-active.js"></script>
<!-- mCustomScrollbar JS
============================================ -->
<script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="js/scrollbar/mCustomScrollbar-active.js"></script>
<!-- metisMenu JS
============================================ -->
<script src="js/metisMenu/metisMenu.min.js"></script>
<script src="js/metisMenu/metisMenu-active.js"></script>


<script src="js/sparkline/jquery.sparkline.min.js"></script>
<script src="js/sparkline/jquery.charts-sparkline.js"></script>
<script src="js/sparkline/sparkline-active.js"></script>
<!-- calendar JS
============================================ -->
<script src="js/calendar/moment.min.js"></script>

<script src="js/calendar/fullcalendar.min.js"></script>
<script src="js/calendar/fullcalendar-active.js"></script>
<!-- plugins JS
============================================ -->
<script src="js/plugins.js"></script>
<!-- main JS
============================================ -->
<script src="js/main.js"></script>

<!-- tawk chat JS  聊天系统js
<script src="js/tawk-chat.js"></script>
============================================ -->

<script src="js/data-table/bootstrap-table.js"></script>
<script src="js/data-table/bootstrap-table-zh-CN.js"></script>

<script src="js/notifications/Lobibox.js"></script>

<script src="js/datepicker/bootstrap-datetimepicker.min.js"></script>
<script src="js/datepicker/bootstrap-datetimepicker.zh-CN.js"></script>

<script src="js/vue.js"></script>
<script src="customjs/eventSourcesNotify.js"></script>
<link rel="stylesheet" href="customcss/ul_style.css">
</body>
<script>
    /**
     * 1. 获取浏览器地址栏，然后截取路径。
     * 2. 根据路径使用jquery的选择器让其背景颜色变一下。
     */
    var url = window.location.href;   //获取浏览器地址栏 http://localhost:8081/my_cart_war_exploded/admin/index.html

    var index = url.lastIndexOf("/");  //获取最后一个 / 所在的索引的位置

    var path = url.substring(index);  // /admin/index.html

    $('a[href$="' + path + '"]').css('background-color', '#f7f8fb');


    //用户登出
    function logOut() {
        $.ajax({
            url: "servlet/end/login",
            method: 'get',
            dataType: "json",
            success:function (datas) {
                console.log("----datas.code----");
                console.log(datas.code);
                if (datas.code>0){
                    console.log("--成功--");
                    window.location.href = datas.data;
                }else {
                    showErrorBox("退出失败");
                }
            }
        })
    }





    // 显示错误提示信息
    function showErrorBox(msgText,codeState) {
        var colors='';
        if (codeState>0){
            colors = 'success'
        }else {
            colors = 'warning';
        }
        Lobibox.notify(colors, {
            size: 'mini',
            delay: 2500,
            delayIndicator: false,
            position: 'center top',//定位
            title: false, //不给title
            msg: msgText,
            sound: false  // 不要音频
        })
    }



</script>
</html>
<script>
    $('#beginRegisterDate, #endRegisterDate').datetimepicker({
        // 格式化 yyyy-mm-dd hh:ii:ss 年-月-日 时-分-秒
        format: 'yyyy-mm-dd hh:ii:ss'
    })
    /**
     //  https://lobianijs.com/site/lobibox#notifications
     // notify() 第一个参数值为：error success  warning  info
     Lobibox.notify('error', {
        size: 'mini', // 值为枚举：normal, mini, large
        title: '提示', // 信息头
        msg: '激活失败, 请联系管理员',  //信息的内容
        delay: 2000,  //提示框持续的时间
        delayIndicator: false,  //特效是否显示, 下面的进度条不显示
        position: 'bottom right',  //控制方向, 有两个单词, 第一个值为top或者bottom, 第二个是left right
        sound: 'error',  //音效的文件名
        // 谷歌浏览器禁止音效自动的播放, 突破限制的方式：chrome://flags -> 搜索： autoplay ->
        // 找到 "Autoplay policy" -> "No user Gusture..." 然后重启。
        soundExt: '.mp3'  //音效的后缀名
    })
     */
    /**
     "rows": [
     {
          "email": "223@qq.com",
          "id": 1,
          "name": "张三",
          "phone": "13000000000",
          "registerDate": 1589353095000,
          "sex": "F",
          "status": 1
        }
     ],
     "total": 1
     }
     */

    var httpHead = "http://localhost/"
    var baseUrl="http://localhost:8080/posterior_system_war_exploded/";
    var baseHttpUrl="http://localhost:8080/posterior_system_war_exploded/user"; //user业务处理地址
    var uploadFileUrl ="http://localhost:8080/posterior_system_war_exploded/file/upload";//上传文件地址
    var baseGoodsUrl = "http://localhost:8080/posterior_system_war_exploded/goods"
    var baseAddressUrl = "http://localhost:8080/posterior_system_war_exploded/address"

    $('#dataTable').bootstrapTable({
        url: baseHttpUrl,  //请求的地址
        method: 'GET', //请求的方式
        // columns: 是定义列的信息， title表头信息, field表示从返回的json数据中取对应的属性的
        columns: [
            {field: 'id', title: 'ID', align: 'center'},
            {field: 'name', title: '姓名', align: 'center'},
            // formatter要接收一个函数, 是对数据进行处理，该函数接收四个参数。
            {field: 'sex', title: '性别', align: 'center', formatter: formatSex},
            {field: 'status', title: '状态', align: 'center', formatter: formatStatus},
            {field: 'phone', title: '电话', align: 'center'},
            {field: 'email', title: '邮件', align: 'center'},
            {field: 'registerDate', title: '注册日期', align: 'center', formatter: formatRegisterDate},
            {title: '操作', formatter: addProcessBtns}
        ],
        // 查询的参数，是根据该方法的返回值来定的, params中默认的数据格式：
        //      {limit: 10, offset: 0, order: "asc", search: undefined, sort: undefined}
        // limit是每页默认的每页显示的数据, offset(中文翻译是偏移量), 映射分页中指的是 beginIndex   select * from user limit offset, 10;
        // order 是查询的顺序; 如果是get请求会默认将该函数的返回值拼接到请求的url后面:
        //                     http://localhost:8081/my_cart_war_exploded/user?offset=0&limit=10&order=asc&method=getUserPageData
        queryParams: function(params) {
            /**
             * 无论是 "初始化" 或者 "refresh" 都会执行该方法，来获取请求的参数.
             * 所以我们无论是 "初始化" 或者 “refresh” 都去获取表单的数据
             */
            var name = $('#name').val();  //获取查询表单name的值
            var sex = $('#gender').val();
            var status = $('#status').val();
            var email = $('#email').val();
            var afterDate =  $('#beginRegisterDate').val(); //重置name
            var endDate = $('#endRegisterDate').val(); //重置name

            params.name = name;
            params.sex = sex;
            params.status = status;

            params.email = email;
            params.afterDate = afterDate;
            params.endDate = endDate;
            return params;
            // 最终的请求会默认帮我们带上这些参数
            //http://localhost:8081/my_cart_war_exploded/user?order=asc&offset=0&limit=10&name=&gender=-1&status=-1&email=&begin=&end=&method=getUserPageData
        },
        pageList: [10, 15, 20],   // 切换每页显示多少条数据
        pagination: true,  //表示意思是要分页, 默认是false
        // 在那边分页，值为 "client", "server", client的意思一次性将数据全部拿到，然后客户端分页。
        // server, 在服务器端分页, 每次查分页的数据的时候到服务器去请求。
        sidePagination: 'server',
        toolbar:'#userTableToolbar'

    })

    /**
     * 最终表格中显示的数据以该函数的返回值为准
     * value是当前格子的值。
     * row是当前行的数据。
     * index是当前数据的索引。
     */
    function formatSex(value, row, index) {
        return 'F' == value ? '女' : '男';
    }

    // 格式化状态
    function formatStatus(value) {
        // 1表示激活状态(要看数据库)
        if(value == 1) {
            return '<span class="label label-success">激活</span>'
        }else {
            return '<span class="label label-danger">禁用</span>'
        }
    }

    //格式化注册日期
    function formatRegisterDate(value) {
        // 使用moment这个库来完成日期的格式化
        return moment(value).format('YYYY-MM-DD HH:mm:ss');
    }

    /**
     * 该方法会返回操作按钮：
     *      1. 查看用户所有的收货地址(必须的)。
     *      2. 对于未激活的用户, 得有激活按钮, 激活的用户不用加。
     */
    function addProcessBtns(value, row) {
        var btns = '<button class="btn btn-info btn-xs" onclick="showTakeDeliveryAddress(' + row.id + ')">查看收货地址</button>' +
            '  <button onclick="showTakeDeliveryShoppingCart(' + row.id + ')" class="btn btn-primary btn-xs">查看购物车</button>';

        //如果用户是未激活状态, 添加激活按钮
        if(row.status != 1) {
            btns += '  <button  class="btn btn-success btn-xs"  onclick="activeUser(' + row.id + ',1)">激活</button>'
        }else{
            btns += '  <button  class="btn btn-danger btn-xs" onclick="activeUser(' + row.id + ',0)">禁用</button>'
        }

        return btns;
    }

    // 查看收货地址
    function showTakeDeliveryAddress(userId) {
        // console.log(userId)
        $('#showAddressModal').modal('show');
        $('#addressDataTable').bootstrapTable({
            url: baseAddressUrl,
            method:"GET",
            columns: [
                {field: 'aname', align: 'center', title: '收件人姓名'},
                {field: 'aphone', align: 'center', title: '收件人电话'},
                {field: 'adetail', align: 'center', title: '收货地址'},
                {field: 'astate', align: 'center', title: '默认地址',
                    formatter: function(value) {
                        if(value == 1) {  //当value的值为1的时候，表示默认收货地址
                            return '<span class="label label-success">默认</span>';
                        }
                        return "否";
                    }
                }
            ],
            // var obj = {age: 10};  obj.name = 'zhangsan';
            queryParams: function(params) {
                params.uId = userId;
                // console.log(params);
                return params;
            },
            pagination: true,  //表示意思是要分页, 默认是false
            // 在那边分页，值为 "client", "server", client的意思一次性将数据全部拿到，然后客户端分页。
            // server, 在服务器端分页, 每次查分页的数据的时候到服务器去请求。
            sidePagination: 'server',
        })
    }



    // 查看购物车
    function showTakeDeliveryShoppingCart(userId) {

         console.log(userId,"tuian")
        $('#showShoppingCart').modal('show');
        $('#shoppingCartDataTable').bootstrapTable({
            url: baseGoodsUrl+"/goodsCart/"+userId,
            method: 'GET',
            columns:[

                {field: 'smallPic', align: 'center', title: '图片',formatter: imgView},
                {field: 'title', align: 'center', title: '商品名',formatter:tetleFormater},
                {field: 'price', align: 'center', title: '价格'},
                {field: 'num', align: 'center', title: '件数'}
            ],
            pagination: true,
            sidePagination: 'server'
        })



    }

    //设置购物车图片
    function imgView(value,row) {
        console.log("图片")
        return '<img style="width: 60px ;height: 80px" src="'+value+'" />';
    }

    //设置商品名
    function tetleFormater(value) {
        return '<div style="width: 300px ;height: 80px">'+value+'</div>';
    }


    //隐藏地址
    function address(){
        destoryTableAndHideModal($('#showAddressModal'),$('#addressDataTable'))
    }

    //隐藏购物车
    function shoping(){
        destoryTableAndHideModal($('#showShoppingCart'),$('#shoppingCartDataTable'))
    }

    // 销毁表格, 然后影藏模态窗
    function destoryTableAndHideModal(modal,dataTable) {
        modal.modal('hide');
        // 因为模态窗中的表格, 没有分页，所以将数据直接缓存在客户端，当重新请求的时候并不会发送网络请求，
        // 导致看不同用户的收货地址的时候, 看到的数据是上一次的，所以每次影藏要将表格销毁掉。
        // https://www.bootstrap-table.com.cn/doc/api/methods/#destroy
        dataTable.bootstrapTable('destroy'); // destroy是固定值
    }



    // 激活用户
    function activeUser(userId ,state) {

        $.ajax({
            url: baseHttpUrl,
            data: {id: userId,status:state},
            dataType: 'json',
            type: 'put',
            // 激活的时候返回的json数据格式：{code: 1, msg: 'success'}
            success: function(_data) {
                // 代表激活成功，成功之后要重新加载表格的数据
                if(_data.code > 0) {
                    // 重新加载表格。 https://www.bootstrap-table.com.cn/doc/api/methods/#refresh
                    $('#dataTable').bootstrapTable('refresh');
                }else { //激活失败, 提示用户
                    Lobibox.notify('info', {
                        title: '提示',
                        msg: '激活失败, 请联系管理员',
                        size: 'mini'
                    })
                }
            }
        })
    }

    // 搜索
    function querySearch() {
        // 解决翻页之后, 还是停留在以前的页面问题, 使用selectPage, 意思是回到第一页
        $('#dataTable').bootstrapTable('selectPage', 1);
    }

    /**
     * 重置搜索条件:
     *    1.将所有的搜索条件归位；
     *    2.刷新表格数据。
     */
    function resetSearch() {
        $('#name').val(''); //重置name
        $('#gender').val('-1'); //重置性别
        $('#status').val('-1'); //重置状态
        $('#email').val('');
        $('#beginRegisterDate').val('');
        $('#endRegisterDate').val('');
        querySearch();
    }

    //导出excel
    function downloadExcel() {
        var name = $('#name').val();  //获取查询表单name的值
        var sex = $('#gender').val();
        var status = $('#status').val();
        var email = $('#email').val();
        var afterDate =  $('#beginRegisterDate').val();
        var endDate = $('#endRegisterDate').val();
        location.href =baseHttpUrl+ "/download"+"?name="+name+"&sex="+sex+"&status="+status+"&email="+email+"&afterDate="+afterDate+"&endDate="+endDate;

    }

    function clickFileInput() {
        $("#fileid").click();
    }


    function uploadExcel(fileData) {
        var excelfile = fileData.files[0];
        // var fileName = file.name; //获取文件名
        // var suffix = fileName.substring(fileName.lastIndexOf('.'));
        // if('.xls' != suffix && '.xlsx' != suffix) {
        //     showErrorBox('请上传正确的excel文件.')
        // }
        $("#fileid").val('');
        var formData = new FormData();
        formData.append("excel",excelfile);
        $.ajax({
            url: baseHttpUrl+"/uploadExcel",
            type: 'post',
            dataType: 'json',
            data: formData,
            /**
             * 内容类型。默认值：application/x-www-form-urlencoded;
             * false表示不设置，将FormData原封不动的直接提价服务器端
             */
            contentType: false,
            /**
             * processData 处理数据， 例如get请求，会将data中的数据，name=张三&password=125,
             * 对于FormData包含文件，此处要为false, 禁止转换
             */
            pageList:[10],
            processData: false,
            success: function(_data) {

                if(_data.code>0){
                    showErrorBox(_data.msg,_data.code);
                }else {
                    showErrorBox(_data.msg,_data.code);
                }
            }
        })
    }


    //用户登出
    function logOut() {



        $.ajax({
            url: baseUrl+"login/out",
            method: 'GET',
            dataType: "json",
            async:true,
            success:function (_data) {
                console.log("----datas.code----");
                console.log(_data.code);
                if (_data.code>0){
                    console.log("--成功--");
                    window.location.href =  baseUrl;
                }else {
                    showErrorBox("退出失败");
                }
            }
        })
    }

</script>
<script src="js/my/headImgAndName.js"></script>